package ssau.knyazev.db.gui.components;

import javax.swing.table.AbstractTableModel;

import ssau.knyazev.db.ModelManager;
import ssau.knyazev.db.core.DBTable;

public class QueryTable extends AbstractTableModel{

	private static final long serialVersionUID = -2648785752915594745L;
	protected DBTable table = null;
	
	public QueryTable(DBTable table){
		this.table = table;
	}
	
	@Override
	public int getRowCount() {
		return table.getValues().length;
	}

	@Override
	public int getColumnCount() {
		return table.getColumnNames().length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return table.getValue(rowIndex, columnIndex);
	}
	
	public String getColumnName(int column) {
        String name = table.getColumnName(column);
        name = ModelManager.getInst().localizedName(name);
        return name;
    }

}
